﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UWP.Douban.Utils
{
    public class DateTimeUtil
    {
        public static string Description(DateTime dateTime)
        {
            var span = DateTime.Now.Subtract(dateTime);

            if (span.TotalDays > 1)
            {
                return string.Format("{0:F0}日前", span.TotalDays);
            }
            if (span.TotalHours > 1)
            {
                return string.Format("{0:F0}小时前", span.TotalHours);
            }
            if (span.TotalMinutes > 1)
            {
                return string.Format("{0:F0}分钟前", span.TotalMinutes);
            }
            if (span.TotalSeconds > 30)
            {
                return string.Format("{0:F0}秒前", span.TotalSeconds);
            }
            return "刚刚";
        }
    }
}
